package cn.remexs.examples.apijson.parser;

import apijson.NotNull;
import apijson.RequestMethod;
import apijson.framework.APIJSONObjectParser;
import apijson.orm.Join;
import apijson.orm.SQLConfig;
import cn.remexs.examples.apijson.config.CustomSQLConfig;

import com.alibaba.fastjson.JSONObject;
import java.util.List;
import javax.servlet.http.HttpSession;

/**简化Parser，getObject和getArray(getArrayConfig)都能用
 * @author remexs
 */
public class CustomObjectParser extends APIJSONObjectParser {

  public CustomObjectParser(
    HttpSession session,
    @NotNull JSONObject request,
    String parentPath,
    SQLConfig arrayConfig,
    boolean isSubquery,
    boolean isTable,
    boolean isArrayMainTable
  )
    throws Exception {
    super(
      session,
      request,
      parentPath,
      arrayConfig,
      isSubquery,
      isTable,
      isArrayMainTable
    );
  }

  @Override
  public SQLConfig newSQLConfig(
    RequestMethod method,
    String table,
    String alias,
    JSONObject request,
    List<Join> joinList,
    boolean isProcedure
  )
    throws Exception {
    return CustomSQLConfig.newSQLConfig(
      method,
      table,
      alias,
      request,
      joinList,
      isProcedure
    );
  }
}
